<?php
class Ckeditor extends Controller {
	public $data 	= 	array();
	public function __construct() {
		parent::Controller();
		$this->load->helper('url'); //You should autoload this one ;)
		$this->load->helper('ckeditor');
		//Ckeditor's configuration
		$this->data['ckeditor'] = array(
			//ID of the textarea that will be replaced
			'id' 	=> 	'content',
			'path'	=>	'js/ckeditor',
			//Optionnal values
			'config' => array(
				'toolbar' 	=> 	"Full", 	//Using the Full toolbar
				'width' 	=> 	"550px",	//Setting a custom width
				'height' 	=> 	'100px',	//Setting a custom height
			),
			//Replacing styles from the "Styles tool"
			'styles' => array(
				//Creating a new style named "style 1"
				'style 1' => array (
					'name' 		=> 	'Blue Title',
					'element' 	=> 	'h2',
					'styles' => array(
						'color' 	=> 	'Blue',
						'font-weight' 	=> 	'bold'
					)
				),
				//Creating a new style named "style 2"
				'style 2' => array (
					'name' 	=> 	'Red Title',
					'element' 	=> 	'h2',
					'styles' => array(
						'color' 		=> 	'Red',
						'font-weight' 		=> 	'bold',
						'text-decoration'	=> 	'underline'
					)
				)
			)
		);
		$this->data['ckeditor_2'] = array(
			//ID of the textarea that will be replaced
			'id' 	=> 	'content_2',
			'path'	=>	'js/ckeditor',
			//Optionnal values
			'config' => array(
				'width' 	=> 	"550px",	//Setting a custom width
				'height' 	=> 	'100px',	//Setting a custom height
				'toolbar' 	=> 	array(	//Setting a custom toolbar
					array('Source','-','Save','NewPage','Preview','-','Templates'),
					array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'),
					array('Undo','Redo','-','Bold', 'Italic'),
					array('Underline', 'Strike'),
					array('Find','Replace','-','SelectAll','RemoveFormat'),
					array('NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'),
					array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
					array('Link','Unlink','Anchor'),
					array('Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
					array('Styles','Format','Font','FontSize'),
					array('TextColor','BGColor'),

					'/'
				)
			),
			//Replacing styles from the "Styles tool"
			'styles' => array(
				//Creating a new style named "style 1"
				'style 3' => array (
					'name' 		=> 	'Green Title',
					'element' 	=> 	'h3',
					'styles' => array(
						'color' 	=> 	'Green',
						'font-weight' 	=> 	'bold'
					)
				)
			)
		);
	}
	public function index() {
		$this->load->view('inc/ckeditor', $this->data);
	}
	
	function getEditor(){
		/*$content = $this->input->post('content');
		echo $content;*/
		if ( isset( $_POST ) )
			$postArray = &$_POST ;			// 4.1.0 or later, use $_POST
		else
			$postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS
		
		foreach ( $postArray as $sForm => $value )
		{
			if ( get_magic_quotes_gpc() )
				$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
			else
			$postedValue = htmlspecialchars( $value ) ;
			//echo $sForm;
			echo $postedValue;
		}
	}
}